/**
 * Created by pankajmishra on 16/01/15.
 */
define(['jquery','mustache','module/template/homeTemplate'], function($, mustache, template){
    return function(url){
        var dom =  $( template[url]),email= dom.find('.js_email');
        dom.find('.js_submit').once('click', function(){

            if(email.val().trim() == ''){
                alert('please enter emails.');
                return;
            }

            $(this).remove();
            $.ajax({url : '/people/sendInvitation', type : "POST", data : {email : email.val()}}).
                done(function(data){
                    alert('Thank you for sending invitation');
                    dom.dialog("close");
                });
        });

        dom.dialog({
            hide: { effect: "explode", duration: 100 },
            modal: true
        });
    }
});